﻿using System;
using System.Net;
using ETModel;

namespace Xfs
{
	[XfsObjectSystem]
	public class XfsNetInnerComponentAwakeSystem : XfsAwakeSystem<XfsNetInnerComponent, XfsSenceType>
	{
		public override void Awake(XfsNetInnerComponent self, XfsSenceType a)
		{
			self.SenceType = a;

			if (self.MessageDispatcher == null)
			{
				self.MessageDispatcher = new XfsInnerMessageDispatcher();
			}
			if (self.Sessions.Count == 0)
			{
				//IPEndPoint _ipEendPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002);
				//self.Get(_ipEendPoint);
				//self.Get(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002));

				self.Get();

				Console.WriteLine(XfsTimeHelper.CurrentTime() + " 51. XfsNetInnerComponent adressSessions: " + self.Sessions.Count);
			}

		}
	}

	public class XfsNetInnerComponentAwake1System : XfsAwakeSystem<XfsNetInnerComponent, XfsSenceType>
	{
		public override void Awake(XfsNetInnerComponent self, XfsSenceType a)
		{
			self.SenceType = a;

			if (self.MessageDispatcher == null)
			{
				self.MessageDispatcher = new XfsInnerMessageDispatcher();
			}
			if (self.Sessions.Count == 0)
			{
				//IPEndPoint _ipEendPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002);
				//self.Get(_ipEendPoint);
				//self.Get(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002));

				self.Get();

				Console.WriteLine(XfsTimeHelper.CurrentTime() + " 51. XfsNetInnerComponent adressSessions: " + self.Sessions.Count);
			}

		}
	}
	[XfsObjectSystem]
	public class XfsNetInnerComponentLoadSystem : XfsLoadSystem<XfsNetInnerComponent>
	{
		public override void Load(XfsNetInnerComponent self)
		{
			if (self.MessageDispatcher == null)
			{
				self.MessageDispatcher = new XfsInnerMessageDispatcher();
			}

			if (self.Sessions.Count == 0)
			{
				//IPEndPoint _ipEendPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002);
				//self.Get(_ipEendPoint);
				//self.Get(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002));

				self.Get();

				Console.WriteLine(XfsTimeHelper.CurrentTime() + " 51. XfsNetInnerComponent adressSessions: " + self.Sessions.Count);
			}
		}
	}

	[XfsObjectSystem]
	public class XfsNetInnerComponentUpdateSystem : XfsUpdateSystem<XfsNetInnerComponent>
	{
		public override void Update(XfsNetInnerComponent self)
		{
			self.Update();
		}
	}

	public static class XfsNetInnerComponentHelper
	{
		public static void Awake(this XfsNetInnerComponent self)
		{
			if (self.MessageDispatcher == null)
			{
				self.MessageDispatcher = new XfsInnerMessageDispatcher();
			}
			if (self.Sessions.Count == 0)
			{
				//IPEndPoint _ipEendPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002);
				//self.Get(_ipEendPoint);
				//self.Get(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4002));

				self.Get();

				Console.WriteLine(XfsTimeHelper.CurrentTime() + " 51. XfsNetInnerComponent adressSessions: " + self.Sessions.Count);

			}
		}

		public static void Update(this XfsNetInnerComponent self)
		{

		}


	}
}